using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using CocaCola_Inventory_System.Data_Access;

namespace CocaCola_Inventory_System.Forms
{
    public partial class StockUser : Form
    {
        public StockUser()
        {
            InitializeComponent();
        }
        DataTable users;
        private void StockUser_Load(object sender, EventArgs e)
        {
            label2.Text = "Stock User is the user who all items \n that are currently in Stock (Not used by anybody) is assigned to";
            retrieve r = new retrieve(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con);
            users =r.getusers();
            comboBox1.DataSource = users;
            comboBox1.DisplayMember = "name";
            comboBox1.ValueMember = "id";
            int id = Common.GetStockUserId(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con);

            cur.Text = r.GetUserNameforuserid(id);

        }

        private void button1_Click(object sender, EventArgs e)
        {
            if (comboBox1.SelectedIndex < 0)
            {
                MessageBox.Show("Please Select a User");
                return;
            }
            if(Common.SetStockUserId(((CocaCola_Inventory_System.Forms.Container)this.MdiParent).con, Convert.ToInt32(comboBox1.SelectedValue)))
                MessageBox.Show("Stock User is Selected Successfully"); 
            else
            MessageBox.Show("Failed To Select User"); 

        }
    }
}